﻿@{
    Layout = "~/Views/Shared/_FormWhite.cshtml";
}

<div class="wrapper animated fadeInRight">
    <form id="form" class="form-horizontal m">
        @*<div class="form-group">
            <label class="col-sm-3 control-label ">AreaId<font class="red"> *</font></label>
            <div class="col-sm-8">
                <input id="areaId" col="AreaId" type="text" class="form-control" />
            </div>
        </div>*@
        @await Html.PartialAsync("/Areas/SystemManage/Shared/AreaFormPartial.cshtml", new ViewDataDictionary(this.ViewData) { { "Label", "2" }, { "Content", "10" } })
        <div class="form-group">
            <label class="col-sm-2 control-label ">预结时间<font class="red"> *</font></label>
            <div class="col-sm-4">
                <input id="statementTime" col="StatementTime" type="text" class="form-control" />
            </div>
            <label class="col-sm-2 control-label ">进展阶段修改时间<font class="red"> *</font></label>
            <div class="col-sm-4">
                <input id="stageTime" col="StageTime" type="text" class="form-control" />
            </div>

        </div>
        <div class="form-group">
            <label class="col-sm-2 control-label ">最近联系时间<font class="red"> *</font></label>
            <div class="col-sm-4">
                <input id="lastTime" col="LastTime" type="text" class="form-control" />
            </div>
            <label class="col-sm-2 control-label ">下一步跟进时间<font class="red"> *</font></label>
            <div class="col-sm-4">
                <input id="nextTime" col="NextTime" type="text" class="form-control" />
            </div>

        </div>

        <div class="form-group">
            <label class="col-sm-2 control-label ">销售人</label>
            <div class="col-sm-4">
                <input id="saler" col="Saler" type="text" class="form-control" />
            </div>
            <label class="col-sm-2 control-label ">客户</label>
            <div class="col-sm-4">
                <input id="clientName" col="ClientName" type="text" class="form-control" />
            </div>
        </div>
        <div class="form-group">
            <label class="col-sm-2 control-label ">客户类型<font class="red"> *</font></label>
            <div class="col-sm-4">
                <div id="clientType" col="ClientType"></div>
            </div>
            <label class="col-sm-2 control-label ">产品<font class="red"> *</font></label>
            <div class="col-sm-4">
                <div id="productId" col="ProductId"></div>
            </div>
        </div>
        <div class="form-group">

            <label class="col-sm-2 control-label ">地址</label>
            <div class="col-sm-4">
                <input id="adress" col="Adress" type="text" class="form-control" />
            </div>

            <label class="col-sm-2 control-label ">数量</label>
            <div class="col-sm-4">
                <input id="productNumber" col="ProductNumber" type="number" min="0" max="99999" class="form-control" />
            </div>
        </div>
        <div class="form-group">
            <label class="col-sm-2 control-label ">竞争品牌数量</label>
            <div class="col-sm-4">
                <input id="contendNumber" col="ContendNumber" type="number" min="0" max="99" class="form-control" />
            </div>
            <label class="col-sm-2 control-label ">竞争机会</label>
            <div class="col-sm-4">
                <input id="opportunitie" col="Opportunitie" type="text" class="form-control" />
            </div>
        </div>
        <div class="form-group">
            <label class="col-sm-2 control-label ">进展阶段</label>
            <div class="col-sm-4">
                <input id="stage" col="Stage" type="text" class="form-control" />
            </div>
            <label class="col-sm-2 control-label ">机会总值</label>
            <div class="col-sm-4">
                <input id="chanceSum" col="ChanceSum" type="text" class="form-control" />
            </div>
        </div>
        <div class="form-group">
            <label class="col-sm-2 control-label ">下一步工作</label>
            <div class="col-sm-4">
                <input id="nextAction" col="NextAction" type="text" class="form-control" />
            </div>
            <label class="col-sm-2 control-label ">竞争对手A</label>
            <div class="col-sm-4">
                <input id="rivalA" col="RivalA" type="text" class="form-control" />
            </div>
        </div>
        <div class="form-group">
            <label class="col-sm-2 control-label ">A的产品型号</label>
            <div class="col-sm-4">
                <input id="productModelA" col="ProductModelA" type="text" class="form-control" />
            </div>
            <label class="col-sm-2 control-label ">竞争对手B</label>
            <div class="col-sm-4">
                <input id="rivalB" col="RivalB" type="text" class="form-control" />
            </div>
        </div>
        <div class="form-group">
            <label class="col-sm-2 control-label ">B的产品型号</label>
            <div class="col-sm-4">
                <input id="productModelB" col="ProductModelB" type="text" class="form-control" />
            </div>
            <label class="col-sm-2 control-label ">客户联系人</label>
            <div class="col-sm-4">
                <input id="contact" col="Contact" type="text" class="form-control" />
            </div>
        </div>
        <div class="form-group">
            <label class="col-sm-2 control-label ">客户联系人电话</label>
            <div class="col-sm-4">
                <input id="contactMobile" col="ContactMobile" type="text" class="form-control" />
            </div>
            <label class="col-sm-2 control-label ">采购联系人</label>
            <div class="col-sm-4">
                <input id="purchase" col="Purchase" type="text" class="form-control" />
            </div>
        </div>
        <div class="form-group">
            <label class="col-sm-2 control-label ">采购联系人电话</label>
            <div class="col-sm-4">
                <input id="purchaseMobile" col="PurchaseMobile" type="text" class="form-control" />
            </div>
            <label class="col-sm-2 control-label ">院长</label>
            <div class="col-sm-4">
                <input id="dean" col="Dean" type="text" class="form-control" />
            </div>
        </div>
        <div class="form-group">
            <label class="col-sm-2 control-label ">院长电话</label>
            <div class="col-sm-4">
                <input id="deanMobile" col="DeanMobile" type="text" class="form-control" />
            </div>
            <label class="col-sm-2 control-label ">信息来源</label>
            <div class="col-sm-4">
                <input id="leadSource" col="LeadSource" type="text" class="form-control" />
            </div>
        </div>
    </form>
</div>

<script type="text/javascript">
    var id = ys.request("id");
    $(function () {
        laydate.render({ elem: '#statementTime', type: 'datetime', format: 'yyyy-MM-dd HH:mm' });
        laydate.render({ elem: '#stageTime', type: 'datetime', format: 'yyyy-MM-dd HH:mm' });
        laydate.render({ elem: '#lastTime', type: 'datetime', format: 'yyyy-MM-dd HH:mm' });
        laydate.render({ elem: '#nextTime', type: 'datetime', format: 'yyyy-MM-dd HH:mm' });

        $("#clientType").ysComboBox({
            url: '@Url.Content("~/SaleManage/ClientType/GetListJson")',
            dataName: "Result",
            key: "Id",
            value: "ClientTypeName",
            class: "form-control",
            multiple: false
        });

        $("#productId").ysComboBox({
            url: '@Url.Content("~/SaleManage/Product/GetListJson")',
            dataName: "Result",
            key: "Id",
            value: "ProductName",
            class: "form-control",
            multiple: false
        });

        getForm();

        $('#form').validate({
            rules: {
                areaId: { required: true }
            }
        });
    });

    function getForm() {
        if (id > 0) {
            ys.ajax({
                url: '@Url.Content("~/SaleManage/Funnel/GetFormJson")' + '?id=' + id,
                type: 'get',
                success: function (obj) {
                    if (obj.Tag == 1) {
                        $('#form').setWebControls(obj.Result);
                    }
                }
            });
        }
        else {
            var defaultData = {};
            $('#form').setWebControls(defaultData);
        }
    }

    function saveForm(index) {
        if ($('#form').validate().form()) {
            var postData = $('#form').getWebControls({ Id: id });
            ys.ajax({
                url: '@Url.Content("~/SaleManage/Funnel/SaveFormJson")',
                type: 'post',
                data: postData,
                success: function (obj) {
                    if (obj.Tag == 1) {
                        ys.msgSuccess(obj.Message);
                        parent.searchGrid();
                        parent.layer.close(index);
                    }
                    else {
                        ys.msgError(obj.Message);
                    }
                }
            });
        }
    }
</script>

